<%--
  @author Duminda Dharmakeerthi
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script src="${pageContext.request.contextPath}/js/validateLand.js" type="text/javascript"></script>
<script type="text/javascript">


    $(document).ready(function () {
        validateLandDetails();
    });

    function validateReject() {
        $("#gov-land-init-info-form").validate({
            rules:{
                approvalNote:{
                    required: true
                }
            },
            messages:{
                approvalNote:{
                    required: "Please enter a comment"
                }
            }
        });
    }
</script>

<div id="init-land-outer" class="form-outer">
    <s:if test="hasActionErrors()">
        <s:div id="message-box" class="message-box">
            <div class="action-err">
                <s:label value="%{getText('error_occurred.label')}"/>
                <s:actionerror/>
            </div>
        </s:div>
    </s:if>
    <s:if test="hasActionMessages()">
        <s:div id="message-box" class="message-box">
            <div class="action-msg">
                <s:actionmessage/>
            </div>
        </s:div>
    </s:if>
    <div id="messageBox" class="action-msg"></div>
    <s:form method="POST" id="gov-land-init-info-form" name="init-land-info" enctype="multipart/form-data">
        <s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
            <h2><s:label value="%{getText('approve_land_info.label')}"/></h2>
        </s:if>
        <s:else>
            <s:if test="land.mode.ordinal() == 1">
                <h2><s:label value="%{getText('detail_land_info.label')}"/></h2>
            </s:if>
            <s:else>
                <h2><s:label value="%{getText('init_land_info.label')}"/></h2>
            </s:else>
        </s:else>

        <div class="form-button-div right-align">
            <hr/>
            <s:if test="user.role.id == \"ORLM\" || user.role.id == \"LO\"">
               <s:if test="land.mode.ordinal() == 1">
                    <s:submit action="saveDetailLandInformationMobile" value="%{getText('next.label')}"
                              onclick="validateFields()"/>
                </s:if>
            </s:if>

            <s:submit cssClass="cancel" action="detailFormMobile" value="%{getText('cancel.label')}"/>
            <br/><br/>
        </div>

        <s:include value="./landDetails.jsp"/>

        <s:include value="./landAlienationInfomation.jsp"/>

        <%--<s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments.label')}"/></td>
                    <td colspan="3"><s:textarea name="land.approvalNote" cssClass="width-595-px"/></td>
                </tr>
            </table>
        </s:if>
        <s:elseif test="land.approvalNote != null && land.approvalNote.length() > 0">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments.label')}"/></td>
                    <td colspan="3">
                        <s:textarea id="approvalNote" readonly="true" name="land.approvalNote" cssClass="width-595-px"/>
                    </td>
                </tr>
            </table>
        </s:elseif>--%>

        <s:if test="land.approvalNote != null && land.approvalNote.length() > 0">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments.label')}"/></td>
                    <td colspan="3">
                        <s:textarea id="approvalNote" readonly="true" name="land.approvalNote" cssClass="width-595-px"/>
                    </td>
                </tr>
            </table>
        </s:if>

        <div class="form-button-div right-align">
            <%--<s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
                <s:submit value="%{getText('reject.label')}" action="rejectLandInformation"/>
                <s:submit value="%{getText('approve.label')}" action="approveLandInformation"/>
            </s:if>
            <s:else>
                <s:if test="land.mode.ordinal() == 1">
                    <s:submit action="saveDetailLandInformationMobile" value="%{getText('next.label')}"
                              onclick="validateFields()"/>
                </s:if>

            </s:else>--%>

            <s:if test="user.role.id == \"ORLM\" || user.role.id == \"LO\"">
               <s:if test="land.mode.ordinal() == 1">
                    <s:submit action="saveDetailLandInformationMobile" value="%{getText('next.label')}"
                              onclick="validateFields()"/>
                </s:if>
            </s:if>

            <s:submit cssClass="cancel" action="detailFormMobile" value="%{getText('cancel.label')}"/>
        </div>
    </s:form>
    <s:form id="load-form">
        <s:hidden id="alienationMethod" name="alienationType"/>
        <s:hidden id="editMode" name="editMode"/>
    </s:form>
</div>
<s:hidden id="pls_enter_reference_no" value="%{getText('pls_enter_reference_no')}"/>
<s:hidden id="pls_enter_name_of_the_land" value="%{getText('pls_enter_name_of_the_land')}"/>
<s:hidden id="pls_enter_valid_no" value="%{getText('pls_enter_valid_no')}"/>
<s:hidden id="pls_enter_name_of_the_land" value="%{getText('pls_enter_name_of_the_land')}"/>
<s:hidden id="pls_enter_plan_no" value="%{getText('pls_enter_plan_no')}"/>
<s:hidden id="pls_enter_lot_no" value="%{getText('pls_enter_lot_no')}"/>
<s:hidden id="pls_select_gn_division" value="%{getText('pls_select_gn_division')}"/>
<s:hidden id="userRole" name="user.role.id"/>
<s:hidden id="pls_select_alienation_method" value="%{getText('pls_select_alienation_method.label')}"/>
